/*
 * Observable.h
 *
 *  Created on: 2011-5-29
 *      Author: yangentao
 */

#ifndef OBSERVABLE_H_
#define OBSERVABLE_H_

#include "../pre.h"

class Observable;

class Observer {
public:
	Observer():sender(0) {
	}
	virtual ~Observer() {
	}
public:
	void onChange(Observable* sender, int msg, any arg);

public:
	Observable* sender;
};

class Observable {
public:
	Observable() {
	}
	virtual ~Observable() {
	}
public:
	void add(int msg, Observer* listener){
//		listeners[msg] = listener;
	}
	void remove(int msg){
		listeners.erase(msg);
	}
	void remove(int msg, Observer* listener){

	}
	void remove(Observer* listener){
		multimap<int, Observer*>::iterator it = listeners.begin();
		while(it != listeners.end()){
//			if(it->sencod == listener){
//				listener
//			}
		}
	}


private:
	multimap<int, Observer*> listeners;
};

#endif /* OBSERVABLE_H_ */
